import * as tslib_1 from "tslib";
import { Component, Injector, HostBinding, ElementRef } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Form, FrameComponent, FARRIS_DEVKIT_FRAME_PROVIDERS, ViewModel, COMMAND_HANDLERS_TOKEN, FRAME_ID, StateMachine, BindingData, Repository, UIState, EXCEPTION_HANDLER, NAMESPACE } from '@farris/devkit';
import { FARRIS_COMMAND_SERVICE_FRAME_PROVIDERS } from '@farris/command-services';
import { KeybindingService } from '@farris/command-services';
import { ActivatedRoute, Router } from '@angular/router';
import { FrmI18nSettingService } from '@gsp-sys/rtf-common';
import { DomSanitizer } from '@angular/platform-browser';
import { FocusInvalidService } from '@farris/command-services';
import { BefLookupRestService, DefaultComboHttpService } from '@farris/bef';
import { ServerSideToken } from '@farris/ui-lookup';
import { ComboServerSideToken } from '@farris/ui-combo-list';
import { WizardService } from '@farris/ui-wizard';
import { LocalizationService } from "@farris/command-services";
import { HyxxsAtqnViewmodel } from '../../viewmodels/hyxxsatqnviewmodel';
import { HyxxRepository } from '../../models/hyxxrepository';
import { LangService } from '../../lang/lang-pipe';
import { HyxxsAtqnViewmodelForm } from '../../viewmodels/form/hyxxsatqnviewmodelform';
import { HyxxsAtqnViewmodelUIState } from '../../viewmodels/uistate/hyxxsatqnviewmodeluistate';
import { hyxxAddh2o7Handler } from '../../viewmodels/handlers/hyxxaddh2o7handler';
import { hyxxRemovefpxzHandler } from '../../viewmodels/handlers/hyxxremovefpxzhandler';
var HyxxsAtqnComponent = /** @class */ (function (_super) {
    tslib_1.__extends(HyxxsAtqnComponent, _super);
    function HyxxsAtqnComponent(wizardSer, keybindingService, langService, route, router, rootElement, localizationService, frmI18nSettingService, focusInvalidService, stateMachine, sanitizer, injector) {
        var _this = _super.call(this, injector) || this;
        _this.wizardSer = wizardSer;
        _this.keybindingService = keybindingService;
        _this.langService = langService;
        _this.route = route;
        _this.router = router;
        _this.rootElement = rootElement;
        _this.localizationService = localizationService;
        _this.frmI18nSettingService = frmI18nSettingService;
        _this.focusInvalidService = focusInvalidService;
        _this.stateMachine = stateMachine;
        _this.sanitizer = sanitizer;
        _this.injector = injector;
        _this.cls = 'f-struct-wrapper ';
        _this.lang = "";
        _this.size = {};
        _this.enabledLanguageList = [];
        _this.tabsToolbarStates = new BehaviorSubject({});
        _this.tabsToolbarVisibleStates = new BehaviorSubject({});
        _this.sectionsToolbarStates = new BehaviorSubject({});
        _this.sectionsToolbarVisibleStates = new BehaviorSubject({});
        _this.basicFormSectionAtqn = {
            position: 'inHead',
            contents: [
                {
                    id: 'toolBarItem_delete',
                    disable: _this.viewModel.stateMachine && !_this.viewModel.stateMachine['canAddDetail'],
                    visible: true,
                    title: _this.langService.transform("toolBarItem_delete", _this.lang, "删除"),
                    click: function ($event) { _this.viewModel.hyxxRemovefpxz($event); },
                    appearance: {
                        "class": "btn btn-secondary f-btn-ml"
                    }
                }
            ]
        };
        _this.SectionbasicformsectionatqnMainTitle = _this.langService.transform("Section/basic-form-section-atqn/mainTitle", _this.lang, "会员信息");
        _this.SectionbasicformsectionatqnSubTitle = _this.langService.transform("Section/basic-form-section-atqn/subTitle", _this.lang, "");
        _this.levelOfMember_6bb3d632_w38u_PlaceHolder = _this.langService.transform("NumericBox/levelOfMember_6bb3d632_w38u/placeHolder", _this.lang, "");
        _this.levelOfMember6bb3d632W38uTextOptions = {
            "type": "number",
            "useThousands": true,
            "precision": 0,
        };
        _this.code_16c18a8c_1272_PlaceHolder = _this.langService.transform("TextBox/code_16c18a8c_1272/placeHolder", _this.lang, "");
        _this.name_fda60829_r2jg_PlaceHolder = _this.langService.transform("TextBox/name_fda60829_r2jg/placeHolder", _this.lang, "");
        _this.remark_a5bfae00_ta9s_PlaceHolder = _this.langService.transform("TextBox/remark_a5bfae00_ta9s/placeHolder", _this.lang, "");
        _this.state_c8a1e18c_27rn_PlaceHolder = _this.langService.transform("TextBox/state_c8a1e18c_27rn/placeHolder", _this.lang, "");
        _this.organization_ab7841d2_0xub_PlaceHolder = _this.langService.transform("TextBox/organization_ab7841d2_0xub/placeHolder", _this.lang, "");
        _this.gender_c9b82b1d_5gi4_PlaceHolder = _this.langService.transform("TextBox/gender_c9b82b1d_5gi4/placeHolder", _this.lang, "");
        _this.countryOrArea_c4f879b9_dl9j_PlaceHolder = _this.langService.transform("TextBox/countryOrArea_c4f879b9_dl9j/placeHolder", _this.lang, "");
        _this.location_7d2b5e9f_atm1_PlaceHolder = _this.langService.transform("TextBox/location_7d2b5e9f_atm1/placeHolder", _this.lang, "");
        _this.idNumber_30140f27_8zgx_PlaceHolder = _this.langService.transform("TextBox/idNumber_30140f27_8zgx/placeHolder", _this.lang, "");
        _this.levelName_f9f3cb1a_3l0s_PlaceHolder = _this.langService.transform("TextBox/levelName_f9f3cb1a_3l0s/placeHolder", _this.lang, "");
        _this.privilege_f3753110_jtin_PlaceHolder = _this.langService.transform("TextBox/privilege_f3753110_jtin/placeHolder", _this.lang, "");
        _this.recommandPeople_78eab758_xt7v_PlaceHolder = _this.langService.transform("TextBox/recommandPeople_78eab758_xt7v/placeHolder", _this.lang, "");
        _this.phoneNumber_5073e9e4_aksd_PlaceHolder = _this.langService.transform("TextBox/phoneNumber_5073e9e4_aksd/placeHolder", _this.lang, "");
        _this.lang = localStorage.getItem('languageCode') || "zh-CHS";
        _this.viewModel.verifycationChanged.subscribe(function (verifyInformations) {
            _this.focusInvalidService.focusInvalidInput(verifyInformations, _this.rootElement);
        });
        if (_this.frmI18nSettingService) {
            var i18nSetting = _this.frmI18nSettingService.getSetting();
            if (i18nSetting && i18nSetting.languages && i18nSetting.languages.length > 0) {
                i18nSetting.languages.forEach(function (item) {
                    _this.enabledLanguageList.push({
                        code: item.code,
                        name: item.name
                    });
                });
            }
            else {
                console.warn("get current enable languages is null. if this occurs,please ensure the form into the framework.");
                _this.enabledLanguageList.push({ "code": "en", "name": "English" });
                _this.enabledLanguageList.push({ "code": "zh-CHS", "name": "中文简体" });
            }
        }
        return _this;
    }
    HyxxsAtqnComponent.prototype.ngOnInit = function () {
        var _this = this;
        if (this.keybindingService) {
            this.viewModel.keybindingMap.forEach(function (keyBinding, method) {
                _this.keybindingService.register(keyBinding, function () {
                    return _this.viewModel[method]();
                });
            });
        }
        this.stateMachine.stateChange.subscribe(function () {
            var states = {
                'toolBarItem_delete': _this.viewModel.stateMachine && !_this.viewModel.stateMachine['canAddDetail'],
            };
            _this.sectionsToolbarStates.next(states);
        });
        this.stateMachine.stateChange.subscribe(function () {
            var visibleStates = {
                'toolBarItem_delete': true,
            };
            _this.sectionsToolbarVisibleStates.next(visibleStates);
        });
        this.onFormLoad();
    };
    HyxxsAtqnComponent.prototype.ngAfterViewInit = function () {
    };
    HyxxsAtqnComponent.prototype.ngOnDestroy = function () {
        // 增加表单的自我销毁
        this.context.dispose && this.context.dispose();
        this.context = null;
        this.subscription = null;
        this.declaration = null;
        this.wizardSer = null;
        this.keybindingService = null;
        this.langService = null;
        this.route = null;
        this.router = null;
        this.rootElement = null;
        this.localizationService = null;
        this.frmI18nSettingService = null;
        this.focusInvalidService = null;
        this.stateMachine = null;
        this.sanitizer = null;
        this.injector = null;
        this.enabledLanguageList = [];
    };
    HyxxsAtqnComponent.prototype.handleSizeChange = function (size) {
        this.size = size;
    };
    HyxxsAtqnComponent.prototype.onFormLoad = function () {
    };
    tslib_1.__decorate([
        HostBinding('class'),
        tslib_1.__metadata("design:type", Object)
    ], HyxxsAtqnComponent.prototype, "cls", void 0);
    HyxxsAtqnComponent = tslib_1.__decorate([
        Component({
            selector: 'app-hyxxsatqncomponent',
            templateUrl: './hyxxsatqncomponent.html',
            styleUrls: ['./hyxxsatqncomponent.scss'],
            providers: [
                FARRIS_DEVKIT_FRAME_PROVIDERS,
                FARRIS_COMMAND_SERVICE_FRAME_PROVIDERS,
                { provide: FRAME_ID, useValue: 'hyxxs-atqn-component' },
                { provide: BindingData, useClass: BindingData },
                { provide: Repository, useExisting: HyxxRepository },
                LangService,
                { provide: NAMESPACE, useValue: '' },
                { provide: ServerSideToken, useClass: BefLookupRestService },
                { provide: ComboServerSideToken, useClass: DefaultComboHttpService },
                { provide: Form, useClass: HyxxsAtqnViewmodelForm },
                { provide: UIState, useClass: HyxxsAtqnViewmodelUIState },
                { provide: ViewModel, useClass: HyxxsAtqnViewmodel },
                { provide: EXCEPTION_HANDLER, useValue: null },
                { provide: COMMAND_HANDLERS_TOKEN, useClass: hyxxAddh2o7Handler, multi: true },
                { provide: COMMAND_HANDLERS_TOKEN, useClass: hyxxRemovefpxzHandler, multi: true },
            ]
        }),
        tslib_1.__metadata("design:paramtypes", [WizardService,
            KeybindingService,
            LangService,
            ActivatedRoute,
            Router,
            ElementRef,
            LocalizationService,
            FrmI18nSettingService,
            FocusInvalidService,
            StateMachine,
            DomSanitizer,
            Injector])
    ], HyxxsAtqnComponent);
    return HyxxsAtqnComponent;
}(FrameComponent));
export { HyxxsAtqnComponent };
